//
//  GoodMoneyTableViewCell.m
//  shanHaiHuiApp
//
//  Created by 小和尚 on 2018/3/10.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "GoodMoneyTableViewCell.h"
@interface GoodMoneyTableViewCell()


Strong UILabel * nameLabel;
Strong UILabel * countLabel;
Strong UILabel * moneyLabel;




@end

@implementation GoodMoneyTableViewCell

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    self = [super initWithCellIdentifier:cellID];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        _picImageView = [UIImageView new];
        _picImageView.image = [UIImage imageNamed:@"shanhaihuilogo"];
        _picImageView.layer.masksToBounds = YES;
        
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.text = @"三只松鼠,三只松鼠,三只松鼠";
        _nameLabel.font = DEF_FontSize_13;
        _nameLabel.textColor = getColor(@"323232");
        _nameLabel.numberOfLines = 0;
        
        _countLabel = [[UILabel alloc] init];
        _countLabel.text = @"X10";
        _countLabel.textColor = getColor(@"323232");
        _countLabel.font = DEF_FontSize_13;
        
        _moneyLabel = [[UILabel alloc] init];
        _moneyLabel.textColor = getColor(@"323232");
        _moneyLabel.text=@"49";
        _moneyLabel.font = DEF_FontSize_13;
        
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = getColor(dividerColor);
        
        [self sd_addSubviews:@[self.picImageView,self.nameLabel,self.countLabel,self.moneyLabel,self.lineView]];
        
       _spreadBtn = [[CLCustomButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH  - 55,  CGRectGetMaxY(_moneyLabel.frame) + 35, 40,40) type:CLCustomButtonLeftImageType imageSize:CGSizeMake(16,8) midmargin:5];
         _spreadBtn.isShowSelectBackgroudColor = NO;
         _spreadBtn.imageView.image = [UIImage imageNamed:@"zhankai"];
         _spreadBtn.titleLabel.text = @"展开";
         _spreadBtn.titleLabel.textColor = getColor(@"CCCCCC");
         _spreadBtn.titleLabel.font = DEF_FontSize_11;
         _spreadBtn.backgroundColor = [UIColor whiteColor];
        
        [self.spreadBtn touchAction:^(CLCustomButton * _Nonnull button) {
           
            if (_getSpreadClick) {
            _getSpreadClick();
            }
            
        }];
        
        [self addSubview:self.spreadBtn];
        
        [self layOutFrame];
    }
    return self;
}

- (void)layOutFrame{
    ws(self)
    [self.picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(UNIT_HEIGHT(15));
        make.left.mas_equalTo(UNIT_WIDTH(15));
        make.width.mas_equalTo(UNIT_WIDTH(40));
        make.height.mas_equalTo(UNIT_HEIGHT(40));
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakself.picImageView.mas_right).offset(UNIT_WIDTH(10));
        make.top.mas_equalTo(UNIT_WIDTH(15));
        make.width.mas_equalTo(UNIT_WIDTH(151));
    }];
    
    [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakself.nameLabel.mas_right).offset(30);
        make.top.mas_equalTo(UNIT_WIDTH(15));
        make.width.mas_equalTo(UNIT_WIDTH(35));
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-15));
        make.top.mas_equalTo(UNIT_WIDTH(15));
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.picImageView.mas_bottom).offset(UNIT_HEIGHT(20));
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(0.5);
    }];
    
}

- (void)setModel:(PayMentGoodModel *)model{
    
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.imagepfilename]];
    self.nameLabel.text = model.spmc;
    self.countLabel.text = [NSString stringWithFormat:@"×%@",model.xssl];
    self.moneyLabel.text = [NSString stringWithFormat:@"￥%@",model.xsje];
}

@end
